<?php
/*
    Copyright (C) 2008 - 2010 Inanta Martsanto
    
    This file is part of Koma.

    Koma is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Koma is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Koma.  If not, see <http://www.gnu.org/licenses/>.
    
    Inanta Martsanto (inanta@inationsoft.com)
*/
class KomaClassMapper
{
	private static $_instance = __CLASS__;
	private $_classMap = array (
                                   //'KomaArray' => 'collection/KomaArray.class',
                                   //'KomaList' => 'collection/KomaList.class',
                                   //'KomaStack' => 'collection/KomaStack.class',
                                   //'KomaQueue' => 'collection/KomaQueue.class',
                                   // Base Class Start //
                                   'KomaObject' => 'base/KomaObject.class',
                                   'KomaSingletonObject' => 'base/KomaSingletonObject.class',
                                   'IKomaSingleton' => 'base/IKomaSingleton.interface',
                                   // Base Class End //
                                   'KomaDebugger' => 'core/KomaDebugger.class',
                                   'KomaTemplate' => 'template/KomaTemplate.class',
                                   // Database Class Start //
				   'KomaDatabase' => 'database/KomaDatabase.class',
				   'IKomaDatabaseDriver' => 'database/IKomaDatabaseDriver.interface',
				   'KomaDatabaseFactory' => 'database/KomaDatabaseFactory.class',
                                   'KomaTableModel' => 'database/KomaTableModel.class',
                                   // Database Class End //
                                   // Handler Class Start //
				   'KomaHandler' => 'handler/KomaHandler.class',
				   'KomaConfigHandler' => 'handler/KomaConfigHandler.class',
				   'KomaUserHandler' => 'handler/KomaUserHandler.class',
                                   'KomaUploadHandler' => 'handler/KomaUploadHandler.class',
                                   // Handler Class End //
                                   'KomaPage' => 'core/KomaPage.class',
                                   'KomaComponent' => 'core/KomaComponent.class',
                                   'KomaComponentAdmin' => 'core/KomaComponentAdmin.class',
				   'KomaBlock' => 'core/KomaBlock.class',
                                   'KomaScriptManager' => 'core/KomaScriptManager.class',
				   'KomaStyleManager' => 'core/KomaStyleManager.class',
                                   'KomaCookie' => 'core/KomaCookie.class',
				   'KomaSession' => 'core/KomaSession.class',
                                   'KomaSessionHandler' => 'handler/KomaSessionHandler.class',
				   'KomaLists' => 'core/KomaLists.class',
				   'KomaRoutines' => 'core/KomaRoutines.class',
				   'KomaAuthentication' => 'core/KomaAuthentication.class',
                                   //'KomaPlugin' => 'core/KomaPlugin.class',
                                   // IO Class Start //
                                   'KomaDirectoryInfo' => 'io/KomaDirectoryInfo.class',
                                   'KomaFileInfo' => 'io/KomaFileInfo.class',
                                   // IO Class End //
                                   // Exception Class Start //
                                   'KomaException' => 'exception/KomaException.class',
                                   'KomaDatabaseException' => 'exception/KomaDatabaseException.class',
                                   'KomaFatalErrorException' => 'exception/KomaFatalErrorException.class',
                                   'KomaPropertyException' => 'exception/KomaPropertyException.class',
                                   'KomaIOException' => 'exception/KomaIOException.class',
				   'KomaFileNotFoundException' => 'exception/KomaFileNotFoundException.class',
				   'KomaUndefinedMethodException' => 'exception/KomaUndefinedMethodException.class',
                                   'KomaOverrideMethodException' => 'exception/KomaOverrideMethodException.class',
                                   'KomaMissingArgumentException' => 'exception/KomaMissingArgumentException.class',
                                   'KomaSubclassException' => 'exception/KomaSubclassException.class',
                                   'KomaWriteableException' => 'exception/KomaWriteableException.class',
                                   'KomaStartupClassException' => 'exception/KomaStartupClassException.class',
				   'KomaTemplateException' => 'exception/KomaTemplateException.class',
                                   'KomaLibraryException' => 'exception/KomaLibraryException.class',
                                   // Exception Class End //
                                   // UI Class Start //
                                   'KomaUI' => 'ui/KomaUI.class',
                                   //--- Panel --- //
				   'KomaPanel' => 'ui/panels/KomaPanel.class',
                                   'KomaContainer' => 'ui/panels/container/KomaContainer.class',
				   'KomaContainerForm' => 'ui/panels/container/KomaContainerForm.class',
                                   'KomaContainerDiv' => 'ui/panels/container/KomaContainerDiv.class',
                                   'KomaContainerScroll' => 'ui/panels/container/KomaContainerScroll.class',
                                   'KomaContainerDraggable' => 'ui/panels/container/KomaContainerDraggable.class',
                                   'KomaContainerDroppable' => 'ui/panels/container/KomaContainerDroppable.class',
				   'KomaLayoutFlowPanel' => 'ui/panels/layout/KomaLayoutFlowPanel.class',
                                   'KomaLayoutTabPanel' => 'ui/panels/layout/KomaLayoutTabPanel.class',
                                   'KomaLayoutStackPanel' => 'ui/panels/layout/KomaLayoutStackPanel.class',
				   'KomaLayoutVerticalPanel' => 'ui/panels/layout/KomaLayoutVerticalPanel.class',
				   'KomaLayoutForm' => 'ui/panels/layout/KomaLayoutForm.class',
                                   'KomaLayoutPopupPanel' => 'ui/panels/layout/KomaLayoutPopupPanel.class',
                                   // --- End Panel --- //
                                   // --- Widgets --- //
                                   'KomaWidget' => 'ui/widgets/KomaWidget.class',
				   'KomaWidgetImage' => 'ui/widgets/static/KomaWidgetImage.class',
				   'KomaWidgetLabel' => 'ui/widgets/static/KomaWidgetLabel.class',
				   'KomaWidgetHTML' => 'ui/widgets/static/KomaWidgetHTML.class',
				   'KomaWidgetHyperlink' => 'ui/widgets/static/KomaWidgetHyperlink.class',
				   'KomaWidgetInput' => 'ui/widgets/form/KomaWidgetInput.class',
				   'KomaWidgetText' => 'ui/widgets/form/KomaWidgetText.class',
				   'KomaWidgetPassword' => 'ui/widgets/form/KomaWidgetPassword.class',
				   'KomaWidgetButton' => 'ui/widgets/form/KomaWidgetButton.class',
				   'KomaWidgetHidden' => 'ui/widgets/form/KomaWidgetHidden.class',
				   'KomaWidgetFileUpload' => 'ui/widgets/form/KomaWidgetFileUpload.class',
				   'KomaWidgetCheckbox' => 'ui/widgets/form/KomaWidgetCheckbox.class',
				   'KomaWidgetRadioButton' => 'ui/widgets/form/KomaWidgetRadioButton.class',
                                   'KomaWidgetRichTextArea' => 'ui/widgets/form/KomaWidgetRichTextArea.class',
				   'KomaWidgetTextArea' => 'ui/widgets/form/KomaWidgetTextArea.class',
				   'KomaWidgetListBox' => 'ui/widgets/form/KomaWidgetListBox.class',
				   'KomaWidgetRadioButtonYN' => 'ui/widgets/form/KomaWidgetRadioButtonYN.class',
				   'KomaWidgetLanguageMenu' => 'ui/widgets/complex/KomaWidgetLanguageMenu.class',
                                   'KomaWidgetDatepicker' => 'ui/widgets/complex/KomaWidgetDatepicker.class',
                                   'KomaWidgetHighlight' => 'ui/widgets/ext/KomaWidgetHighlight.class',
                                   //'KomaWidgetError' => 'ui/widgets/ext/KomaWidgetError.class',
				   //'KomaWidgetDialog' => 'ui/widgets/complex/KomaWidgetDialog.class',
                                   // --- End Widgets --- //
                                   // --- Validator --- //
                                   'KomaValidatorManager' => 'ui/validators/KomaValidatorManager.class',
                                   'KomaValidator' => 'ui/validators/KomaValidator.class',
                                   'KomaRequiredFieldValidator' => 'ui/validators/KomaRequiredFieldValidator.class',
                                   'KomaEmailValidator' => 'ui/validators/KomaEmailValidator.class',
                                   'KomaURLValidator' => 'ui/validators/KomaURLValidator.class',
                                   'KomaMinLengthValidator' => 'ui/validators/KomaMinLengthValidator.class',
                                   'KomaMaxLengthValidator' => 'ui/validators/KomaMaxLengthValidator.class',
                                   'KomaMinValidator' => 'ui/validators/KomaMinValidator.class',
                                   'KomaMaxValidator' => 'ui/validators/KomaMaxValidator.class',
                                   'KomaNumberValidator' => 'ui/validators/KomaNumberValidator.class',
                                   'KomaRemoteValidator' => 'ui/validators/KomaRemoteValidator.class',
                                   'KomaRangeValidator' => 'ui/validators/KomaRangeValidator.class',
                                   'KomaCompareValidator' => 'ui/validators/KomaCompareValidator.class'
                                   // --- End Validator --- //
                                   // UI Class End //
				   );
	
	function getClassPath($classname)
	{
		if(isset($this->_classMap[$classname]) && file_exists(KOMA_CLASS_PATH.'/'.$this->_classMap[$classname].'.php')) return KOMA_CLASS_PATH.'/'.$this->_classMap[$classname].'.php';
		
		return false;
	}
        
        function addClassPath($classmap = array())
        {
                if(isset($classmap['name']) && isset($classmap['path'])) $this->_classMap[$classmap['name']] = $classmap['path'].'/'.$classmap['name'].'.class';
        }
	
	static function getInstance()
	{
                return is_object(self::$_instance) ? self::$_instance : (self::$_instance = new self::$_instance);
	}
}


?>